/*
* =====================================================================================
*
*       Filename:  feedbackWindow.cpp
*
*        Version:  1.3
*        Created:  09/11/13 12:50:50
*
*         Author:  LIU RENSHENG (A0105649B), roastedbill@gmail.com
*   Organization:  NUS, SoC
*
* =====================================================================================
*/

#include "feedbackWindow.h"  

//@author A0105649B
feedbackWindow::feedbackWindow(QString feedBack, QPoint parentPos,QPoint relativePos, QWidget *parent)
	: QWidget(parent)//@ A0105649B
{
	ui.setupUi(this);
	changeDialogStyle(parentPos,relativePos);
	ui.textFeedBack->setText(feedBack);
	connect(this, SIGNAL(returnPressed()), this, SLOT(close()));
	connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(close()));
	return;
}

feedbackWindow::~feedbackWindow(){}

void feedbackWindow::changeDialogStyle(QPoint parentPos, QPoint relativePos){//@ A0105649B
	this->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
	this->setStyleSheet(feedBckWidgetStyle);
	this->setAttribute(Qt::WA_TranslucentBackground);
	this->move(parentPos + relativePos);
    return;
}

void feedbackWindow::keyPressEvent(QKeyEvent *keyInput ){//@ A0105649B
	this->close();
	return;
}

// Mouse event to move
void feedbackWindow::mousePressEvent(QMouseEvent *event){//@ A0105649B                                                                                                        
	this->windowPos = this->pos();   
	this->mousePos = event->globalPos();  
	this->dPos = mousePos - windowPos;  
	return;
}  

void feedbackWindow::mouseMoveEvent(QMouseEvent *event){//@ A0105649B   
	this->move(event->globalPos() - this->dPos);  
	return;
} 
//@ A0105649B